package a.b.mvc6;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Aspect
public class MyAop {


    @Pointcut("execution(* a.b.mvc6.service..*(..))")
    public void serviceErrorLog() {}
    @Pointcut("execution(* a.b.mvc6.mapper..*(..))")
    public void mapperLog() {}

    @AfterThrowing(value = "serviceErrorLog()", throwing = "e")
    public void afterThrowing(JoinPoint jp, Exception e) {
        String name = jp.getSignature().getName();
        log.error("{}方法抛出了异常: {}", name, e.getMessage(), e);
    }
}
